using FirstTea.Application.DTOs;
using FirstTea.Application.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;

namespace FirstTea.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class AuthController : ControllerBase
    {
        private readonly IAuthService _authService;
        public AuthController(IAuthService authService)
        {
            _authService = authService;
        }

        [HttpPost("register")]
        public async Task<ActionResult<AuthResponseDto>> Register([FromBody] UserDto dto)
        {
            var result = await _authService.RegisterAsync(dto.Username ?? "", dto.Email ?? "", dto.Password ?? "");
            return Ok(result);
        }

        [HttpPost("login")]
        public async Task<ActionResult<AuthResponseDto>> Login([FromBody] UserLoginDto dto)
        {
            var result = await _authService.LoginAsync(dto.Username ?? "", dto.Password ?? "");
            return Ok(result);
        }
    }
}
// ...existing code...
